<?php defined('SYSTEM_IN') or exit('Access Denied');?>
<?php include page('header_base');?>
<title>客服消息</title>
<link href="<?php echo RESOURCE_ROOT;?>public/weui.min.css" rel="stylesheet">
<link href="<?php echo RESOURCE_ROOT;?>public/weui.plus.css?v=2" rel="stylesheet">

<div class="weui-cells_form" style="  margin-bottom:50px;   border-bottom: 0px solid #FFF;   margin-top: 0;">
	 <div class="page_topbar" >
         <a href="<?php echo create_url('mobile',array('act' => 'center','do' => 'member','m'=>'eshop'));?>" class="back"  style="color: #fff;text-align:center;"><i class="fa fa-angle-left"></i></a>
        <div class="title" style="color: #fff;text-align:center;">客服消息</div>
    </div>
    <form id="form_id" action="" onsubmit="return submit_message();" method="post">
    <div class="weui-cells__title">发送消息</div>
    <div class="weui-cells weui-cells__form">
        <div class="weui-cell">
            <div class="weui-cell__bd weui-cell__primary">
                <textarea class="weui-textarea" name="data[content]" placeholder="请输入消息" rows="3"></textarea>
                <div class="weui-textarea-counter"><span class="words_count" max-count="200">0</span>/200</div>
            </div>
        </div>
    </div>
    <div class="weui-btn-area">
        <input type="submit" name="submit" value="发送" class="weui-btn weui-btn_primary">
    </div>
    </form>
    <div class="weui-cells__title">历史消息</div> 
    <?php foreach($list as $row) { ?>
    <div class="weui-cells__title"><?php echo $row["timestamp"] ?></div>
       <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label" style="width:50px;"><?php if($row["type"] == 0) echo "我";else echo "客服" ?>：</label>
        </div>
        <div class="weui-cell__bd">
          <div class="weui_cell_ft"><?php echo $row["content"] ?></div>
        </div>
      
    </div>
    <?php }?>
</div>
<script>
    $("textarea").bind('input propertychange',function(event){

        var countVar = $(this).parent().find("div .words_count");
        var max_count = parseInt(countVar.attr("max-count"));
        if($(this).val().length <= max_count){
            countVar.html($(this).val().length);
        }
        else{
            alert("最多可输入"+max_count+"个字符");
            $(this).val($(this).val().substr(0,max_count));
        }
    });
        

    function submit_message(){
        if($("textarea").val().length == 0){
            alert("请输入内容！");
            return false;
        }
        return true;
    }
</script>
 
<?php  $show_footer=true;?>
<?php include page('footer_menu');?>
<?php include page('footer_base');?>